﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nRoute.Navigation;
using System.Windows.Threading;
using nRoute.ApplicationServices;
using nRoute.Components;

namespace nRoute.Samples.FutureDesktop.ViewModels
{
    public class ProxyNavigationHandler 
        : INavigationHandler
    {
        public event EventHandler NavigationRequested;

        public void ProcessRequest(NavigationRequest request, Action<bool> requestCallback)
        {
            if (NavigationRequested != null) NavigationRequested(this, EventArgs.Empty);

            var _timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1) };
            _timer.Tick += (s1, e1) =>
            {
                _timer.Stop();
                NavigationService.Navigate(request);
            };
            _timer.Start();
        }

        public void ProcessResponse(NavigationResponse response)
        {
            // do nothing
        }
    }
}
